package beans;

import java.sql.Timestamp;
import java.sql.Blob;
import java.sql.Date;
import java.util.Calendar;

/**
 * Bean for managing Users data extracted from the database;
 * each bean represents ONE user instance.
 * Besides all the attributes of the USERR table, a isValid boolean field is addedd to validate login.
 * @author Francesco Anderloni
 * @version 2
 */
public class UserBean {
	private String email;			//Email=Username
	private String password;		//Password
	private String name;    		//Full Name    
	private Boolean genderMale;   	//Gender (TRUE=male, FALSE=female)
	private Date birthDate;    		//Date of Birth
	private String photoURL;    	//Profile Pic URL
	private int phone;    			//Phone Number
	private Boolean setting1;       //Settings
	private int setting2;    
	private Timestamp lastLogin;	//Last Seen Date
	private Timestamp registration; //Registration Date
	private Boolean isAdmin;   		//Admin Flag
	private String city;			//City
	private String region;			//Region
	private String country;			//Country
	public Boolean valid;
	private int points;
	private int hostToGuestRating;
	private int guestToHostRating;
	private int totalHosted;
	private int totalAttended;
	private double hostRatingAvg;
	private double guestRatingAvg;

	public UserBean() {}

	public void setEmail(String str) {
		email = str;
	}
	public String getEmail() {
		return email;
	}

	public void setPassword(String str) {
		password = str;
	}
	public String getPassword() {
		return password;
	}

	public void setName(String str) {
		name = str;
	}
	public String getName() {
		return name;
	}    

	public void setGenderMale(Boolean gen) {
		genderMale = gen;
	}
	public Boolean getGenderMale() { 
		return genderMale;
	}

	public void setBirthDate(Date dat) {
		birthDate = dat;
	}
	public Date getBirthDate() { 
		return birthDate;
	}

	public void setPhotoURL(String str) {
		photoURL = str;
	}
	public String getPhotoURL() { 
		return photoURL;
	}

	public void setPhone(int str) {
		phone = str;
	}
	public int getPhone() { 
		return phone;
	}

	public void setCity(String str){
		city = str;
	}
	public String getCity() { 
		return city;
	}

	public void setCountry(String str){
		country = str;
	}
	public String getCountry() { 
		return country;
	}

	public void setSetting1(Boolean str){
		setting1 = str;
	}
	public Boolean getSetting1() { 
		return setting1;
	}

	public void setSetting2(int str){
		setting2 = str;
	}
	public int getSetting2() { 
		return setting2;
	}

	public void setLastLogin(Timestamp str){
		lastLogin = str;
	}
	public Timestamp getLastLogin() { 
		return lastLogin;
	}

	public void setRegistration(Timestamp num) { 
		registration = num;
	}
	public Timestamp getRegistration() { 
		return registration;
	}

	public void setAdmin(Boolean str) {
		isAdmin = str;
	}
	public Boolean getAdmin() { 
		return isAdmin;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	/**
	 * Method for calculate the user's age in years given his/her birthdate and the current date.
	 * @return An int that represents the user's age in years.
	 */
	public int getAgeYears() {
		Calendar dob = Calendar.getInstance();  
		dob.setTime(birthDate);  
		Calendar today = Calendar.getInstance();  
		int ageyears = today.get(Calendar.YEAR) - dob.get(Calendar.YEAR);  
		if (today.get(Calendar.DAY_OF_YEAR) < dob.get(Calendar.DAY_OF_YEAR))  
			ageyears--; 
		return ageyears;
	}

	public boolean isValid() {
		return valid;
	}

	public void setValid(boolean newValid) {
		valid = newValid;
	}

	public int getPoints() {
		return points;
	}

	public void setPoints(int points) {
		this.points = points;
	}

	public int getHostToGuestRating() {
		return hostToGuestRating;
	}

	public void setHostToGuestRating(int hostToGuestRating) {
		this.hostToGuestRating = hostToGuestRating;
	}

	public int getGuestToHostRating() {
		return guestToHostRating;
	}

	public void setGuestToHostRating(int guestToHostRating) {
		this.guestToHostRating = guestToHostRating;
	}

	public int getTotalHosted() {
		return totalHosted;
	}

	public void setTotalHosted(int totalHosted) {
		this.totalHosted = totalHosted;
	}

	public int getTotalAttended() {
		return totalAttended;
	}

	public void setTotalAttended(int totalAttended) {
		this.totalAttended = totalAttended;
	}

	public double getHostRatingAvg() {
		return hostRatingAvg;
	}

	public void setHostRatingAvg(double hostRatingAvg) {
		this.hostRatingAvg = hostRatingAvg;
	}

	public double getGuestRatingAvg() {
		return guestRatingAvg;
	}

	public void setGuestRatingAvg(double guestRatingAvg) {
		this.guestRatingAvg = guestRatingAvg;
	}
}
